//
//  ZZLCRegisterVC.m
//  ZZLC
//
//  Created by 杨春至 on 2017/12/14.
//  Copyright © 2017年 ZhongZeng. All rights reserved.
//

#import "PersonForgetTrade.h"
#import "ZZHelper.h"
@interface PersonForgetTrade ()<UITextFieldDelegate>

@end

@implementation PersonForgetTrade

- (void)viewDidLoad {
        K_WS(weakSelf);
    [super viewDidLoad];
        self.title = @"设置新密码";
        self.inputPWDTF.keyboardType = UIKeyboardTypeNumberPad;
        self.vadidatePWDTF.keyboardType = UIKeyboardTypeNumberPad;
        self.inputPWDTF.placeholder = @"请设置交易密码";
        self.vadidatePWDTF.placeholder = @"请重复交易密码";
        self.inputPWDTF.delegate = self;
        self.vadidatePWDTF.delegate = self;
   

    [self.nextStepBtn bk_whenTapped:^{
       
            [weakSelf tradePWDNetworking];

     
    }];
    // Do any additional setup after loading the view from its nib.
}

//type 0修改登录密码，1修改交易密码
//注册页面设置登录密码
//registPlatform 0:web端注册; 1:Android移动端; 2:IOS移动端; 3:微信注册;'


//忘记密码时修改登录密码

- (void)tradePWDNetworking
{
//
    if (self.inputPWDTF.text.length!=6) {
        [QMUITips showError:@"请输入6位数字" inView:self.view hideAfterDelay:1.2];
        return;
    }
    if (![self.inputPWDTF.text isEqualToString:self.vadidatePWDTF.text]) {
        [QMUITips showError:@"两次密码不一致" inView:self.view hideAfterDelay:1.2];
        return;
    }
    if (![self isNum:self.inputPWDTF.text]) {
        [QMUITips showError:@"密码格式错误" detailText:@"请输入6位数字"  inView:self.view hideAfterDelay:1.2];
        return;
    }
    [NetWorkingManager postWithRequestUrl:@"findPwdUpdatePwd" AndParameters:@{@"parameters":[@{@"username":self.phoneStr,@"password":self.inputPWDTF.text,@"pwd":self.vadidatePWDTF.text,@"type":@"1",@"phoneId":[ZZHelper deviceIPAdress],@"authorization":[UserModel authorization]} DataTOjsonStringAndAddVersion]} AndRequestBlock:^(NSDictionary *responseObject) {
        [QMUITips showSucceed:responseObject[@"message"] inView:[UIApplication sharedApplication].keyWindow hideAfterDelay:1.8];
        [self.navigationController popToRootViewControllerAnimated:YES];
    } FailBlock:^(NSDictionary *errDic) {
        
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//判断是否纯数字
- (BOOL)isNum:(NSString *)checkedNumString {
    checkedNumString = [checkedNumString stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]];
    if(checkedNumString.length > 0) {
        return NO;
    }
    return YES;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
    NSString *lastStr = [textField.text stringByReplacingCharactersInRange:range withString:string];
    //    textField.text = lastStr;
    if (lastStr.length>6) {
        return NO;
    }
    return YES;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
